﻿@{
    ViewBag.Title = "Cron的使用";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<link href="~/Content/BeginnerAdmin/plugins/layui/css/layui.css" rel="stylesheet" />
<link href="~/Content/BeginnerAdmin/css/global.css" rel="stylesheet" />
<script src="~/Js/lib/jquery-3.2.1/jquery-3.2.1.js"></script>
<script src="~/Js/lib/layer/layer.js"></script>
<script src="~/Js/lib/jquery-3.2.1/jquery-3.2.1.min.js"></script>


<div class="layui-form-item">
    <label class="layui-form-label">Cron表达式</label>
    <div class="layui-input-block" style="width:200px">
        <input type="text" id="Cron" name="title" onclick="SetCron()" required lay-verify="required" placeholder="点击设置Cron表达式" autocomplete="off" class="layui-input">
    </div>
</div>

<fieldset class="layui-elem-field site-demo-button">
    <legend>任务控制区</legend>
    <div>
        <button id="OpenTask" class="layui-btn">开启任务</button>
        <button id="CloseTask" class="layui-btn layui-btn-danger">关闭任务</button>
    </div>
</fieldset>

<script type="text/javascript">
    function SetCron() {
        layer.open({
            type: 2,
            title: "设置Cron表达式",
            area: ['870px', '660px'],
            fixed: false, //不固定
            maxmin: true,
            content: '/Quartz/SetCron'
        });
       // window.open("/Quartz/SetCron", "", "top=100,left=300,width=870,height=660");
    }

    $(document).ready(function () {
        $("#OpenTask").click(function () {
            var cron = $("#Cron").val();
            if (cron === '') {
                layer.tips('请设置Cron表达式', '#Cron', {
                    tips: 3
                });
                return false;
            }
            $.ajax({
                url: "CronQuartzs",
                type: 'post',
                data: { cron: cron },
                dataType: "json",
                async: "false",
                success: function (data) {
                    if (data.ResultSign === 0) {
                        layer.alert("开启成功");
                    } else {
                        layer.alert("开启失败--" + "错误信息：" + data.Message);
                    }
                }
            });
        });
        $("#CloseTask").click(function () {
            $.ajax({
                url: "CloseTask",
                type: 'post',
                data: {},
                dataType: "json",
                async: "false",
                success: function (data) {
                    if (data.ResultSign === 0) {
                        layer.alert("关闭成功");
                    } else {
                        layer.alert("关闭失败--" + "错误信息：" + data.Message);
                    }
                }
            });
        });
    });
</script>